package com.siyoumi.app.modules.user.service;

import com.siyoumi.app.entity.SysAbc;
import com.siyoumi.app.modules.user.vo.VoSaleSettingTxt00;
import com.siyoumi.app.service.SysAbcService;
import com.siyoumi.component.XRedis;
import com.siyoumi.component.XSpringContext;
import com.siyoumi.service.IWebService;
import com.siyoumi.util.XJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

//设置
@Slf4j
@Service
public class SvcSaleSetting
        implements IWebService {
    static public SvcSaleSetting getBean() {
        return XSpringContext.getBean(SvcSaleSetting.class);
    }

    static public SysAbcService getApp() {
        return SysAbcService.getBean();
    }

    public SysAbc getSetting() {
        return XRedis.getBean().getAndSetData(getApp().getEntityCacheKey("sale_setting"), k -> {
            return getApp().getEntityByUix("sale_setting");
        }, SysAbc.class);
    }

    //提现相关
    public VoSaleSettingTxt00 getSettingTxt00() {
        SysAbc setting = getSetting();
        if (setting == null || setting.getAbc_txt_00() == null) {
            return new VoSaleSettingTxt00();
        }

        return XJson.parseObject(setting.getAbc_txt_00(), VoSaleSettingTxt00.class);
    }
}
